<html>
    <head>
        <title>Try Python in the Browser: an IronPython and Silverlight 2 Interactive Interpreter</title>
        <style type="text/css">
          body { font-size: 1.25em; font-family: verdana;}
          #interpreterhost {
            font-family: monospace;
            margin: 20px;
          }
          #interpreter {
            font-size: 1em;
            font-family: monospace;
          }
          #examples {
              margin-left: 20px;
          }
        </style>

        <!-- Formatting for DLR error handling -->
        <link type="text/css" rel="stylesheet" href="assets/stylesheets/error.css" />
        <!-- Defines "onSilverlightError" function for Silverlight plugin -->
        <script type="text/javascript" src="assets/javascript/error.js"></script>
        <script type="text/javascript" src="assets/javascript/cursor_pos.js"></script>
        <script type="text/javascript" src="assets/javascript/onkeypress.js"></script>
    </head>

    <body>
        <h1>Try Python in the Browser: an IronPython and Silverlight 2 Interactive Interpreter</h1>
      <ul>
          <li><a href="http://www.trypython.org">Try Python in the Browser</a></li>
          <li><a href="http://code.google.com/p/pythoninthebrowser/">Project Home Page</a></li>
          <li>Written by <a href="http://www.voidspace.org.uk/python/weblog/index.shtml">Michael Foord</a></li>
          <li><a href="http://www.ironpythoninaction.com/">IronPython in Action</a></li>
      </ul>

        <div id="examples">
            <a id="restore" href="#examples">Standard</a> - <a id="example1" href="#examples">List Comprehension</a> - <a id="example2" href="#examples">Functions</a>
            <div  id="example_output" style="visible: false;">&nbsp;</div>
        </div>
            
        <div id="interpreterhost">
          <textarea id="interpreter" onkeydown="return KeyPress(event);" cols="60" rows="15" 
           oncontextmenu="return false;" disabled="true">Python in the browser starting (requires Silverlight 2)...</textarea>
          <!--
          <div><span id="debugging">&nbsp;</span>&nbsp;<span id="debugging2">&nbsp;</span>&nbsp;<span id="debugging3">&nbsp;</span></div>
          -->
        </div>
        <!--
          Syntax/Runtime errors from Silverlight will be displayed here.
          This will contain debugging information and should be removed
          or hidden when debugging is completed
        -->
        <div id='errorLocation' style="font-size: small;color: Gray;"></div>

        <div id="SilverlightControlHost" width="200" height="240" style="float: right;">

          <object id="SilverlightControl" data="data:application/x-silverlight," type="application/x-silverlight-2" width="200" height="200">
            <param name="source" value="app.xap"/>
            <param name="onerror" value="onSilverlightError" />
            <param name="background" value="white" />
            <param name="initParams" value="debug=true, reportErrors=errorLocation" />
            <param name="windowless" value="true" />


            <a href="http://go.microsoft.com/fwlink/?LinkID=115261" style="text-decoration: none;">
              <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/>
            </a>
          </object>
          <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe>

        </div>

        <div id="introduction">
            <p>An interactive <a href="http://www.python.org/">Python</a> interpreter that runs in the browser, using <a href="http://silverlight.net/GetStarted/">Silverlight 2</a> and <a href="http://www.codeplex.com/IronPython">IronPython</a>.</p>

            <p>This is ideal for tutorials and documentation, where example Python code can actually be tried in the browser.</p>

            <p>It requires Silverlight 2, and the Python version is 2.5.</p>

            <p>The interpreter runs in an HTML textarea, with Javascript that communicates with Silverlight and prevents you deleting text from the console except after the interactive prompt.</p>

            <p>Target browsers are Firefox 2 &amp; 3, Safari and IE 7 &amp; 8. (It won't work in other browsers until there is a version of Silverlight that works with them.)</p>

            <p>The project is a combination of IronPython (for the interpreter loop), Javascript (for the 'console behaviour' in the textarea) and C# (as a helper to call into Silverlight from Javascript). On every keypress Javascript calls into IronPython (via the C#!). If the keypress is an 'enter', then it pushes the current line into the interpreter loop (which uses the standard library <a href="http://docs.python.org/lib/module-code.html">code module</a>). Stdout is diverted to print into the textarea, where tracebacks are also sent. If you are attempting to type over, or delete, previous output then the keypress is cancelled.</p>

            <p>Silverlight 2 is currently only available for Windows and Mac OS X, with the Firefox, Safari or IE browsers. Linux support is in the works via the <a href="http://www.mono-project.com/Moonlight">Moonlight project</a> from Mono.</p>

    </body>
</html>